package com.ljh.controller;

import com.ljh.pojo.Song;
import com.ljh.service.CartService;
import com.ljh.service.SongService;
import com.ljh.utils.Result;
import com.ljh.vo.ListSongVo;
import com.ljh.vo.SongListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 分类页面查询
 */
@RestController
@RequestMapping("cart")
@Api(description = "分类接口管理")
@CrossOrigin
public class CartController {

    @Autowired
    CartService cartService;
    @Autowired
    SongService songService;


    /**
     * 通过头部的分类栏来查找该页面的信息
     * @param id
     * @return
     */
    @RequestMapping("find")
    @ApiOperation(value = "通过头部的分类栏来查找该页面的信息")
    public Result findStyle(Integer id){
        ListSongVo listSongVo = new ListSongVo();
        switch (id){
            case 0:
                listSongVo =  cartService.findStyle("民谣");
                break;
            case 1:
                listSongVo = cartService.findStyle("轻音乐");
                break;
            case 2:
                listSongVo = cartService.findStyle("流行");
                break;
            case 3:
                listSongVo = cartService.findStyle("说唱");
                break;
            case 4:
                listSongVo = cartService.findStyle("爵士");
                break;
            case 5:
                listSongVo = cartService.findStyle("摇滚");
                break;
        }
        return Result.success(listSongVo);
    }

    /**
     * 每次推荐功能
     * @return
     */
    @RequestMapping("every")
    @ApiOperation("每次推荐功能")
    public Result findEveryTui(){
        List<Song> nineSongs = songService.findNineSongs(20);
        return Result.success(nineSongs);
    }

    /**
     * 查找热门的歌曲
     * @return
     */
    @RequestMapping("host15")
    @ApiOperation("查找热门的歌曲")
    public Result findHost15(){
        List<Song> host15 = songService.findHost15();
        return Result.success(host15);
    }

    /**
     * 查找最新的15条数据
     * @return
     */
    @RequestMapping("new15")
    @ApiOperation("查找最新的15条数据")
    public Result findNew15(){
        List<Song> new15 = songService.findNew15();
        return Result.success(new15);
    }
}
